Repository navigation
fix: distinguish aborted requests from timeouts with SdkErrorCode.RequestAborted - #3252
Open
Anshuman-Singhal wants to merge 1 commit into
Open
Anshuman-Singhal wants to merge 1 commit into
Anshuman-Singhal wants to merge 1 commit into
Conversation
…uestAborted Fixes modelcontextprotocol#2165. Cancelling a request via AbortSignal rejected with REQUEST_TIMEOUT, the same code as a real timeout, so callers could not tell a deliberate cancellation apart from a timeout. Aborts now reject with the new REQUEST_ABORTED code, in Protocol.request, the client cache and subscriptions/listen guards, and the multi-round-trip pacing delay. A genuine timeout still rejects with REQUEST_TIMEOUT, including a timeout set with AbortSignal.timeout().
🦋 Changeset detectedLatest commit: 96288c6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@modelcontextprotocol/client
@modelcontextprotocol/codemod
@modelcontextprotocol/core
@modelcontextprotocol/server
@modelcontextprotocol/server-legacy
@modelcontextprotocol/express
@modelcontextprotocol/fastify
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2165
Cancelling a request via AbortSignal rejected with REQUEST_TIMEOUT, the same code as a real timeout, so callers could not tell a deliberate cancellation apart from a timeout.
This change adds a new
SdkErrorCode.RequestAbortedcode (REQUEST_ABORTED) and a shared helper,sdkErrorForAbortReason(reason), and routes abort paths through it:Protocol.request: thecancel()path and the already-aborted early path._serveFromCache) andsubscriptions/listenpre-aborted guards.inputRequiredDriversleep abort paths).instrumentation:outcomeForErrormaps RequestAborted tocancelled.An SdkError passed as the abort reason is still rethrown untouched, and a genuine timeout still rejects with REQUEST_TIMEOUT, including a timeout set with
AbortSignal.timeout()(its TimeoutError reason keeps RequestTimeout).Tests updated:
abortReasonPassthrough.test.ts(old pin flipped to RequestAborted, plus an in-flight abort test and anAbortSignal.timeout()carve-out test),errorSurfacePins.test.ts(new enum member pinned),listen.test.ts, andresponseCache.test.ts. Includes a changeset (client and server, patch).Verified locally: core-internal 1861 tests pass, client 1115 tests pass, server 725 tests pass. Typecheck, eslint, and prettier are clean.